const http = require("http");
const path = require("path"); // 处理路径相关
const fs = require("fs"); // 操作文件

const server = http.createServer((req, res) => {
  fs.readFile(path.resolve(__dirname, "./a.js"), "utf-8", (error, result) => {
    console.log(result);

    res.writeHead(200, { "Content-Type": "text/javascript; charset=utf-8" });
    res.end(result);
  });
});

server.listen(3000, () => {
  console.log("服务启动成功");
});
